<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add Delete User page</title>
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" />
<link rel="stylesheet" href="css/jquery-ui-1.10.3.css" />
<link rel="stylesheet" href="css/AddDeleteUser.css" />
<style type="text/css">
		.errors {
			background-color: #FFCCCC;
			border: 1px solid #CC0000;
			width: 400px;
			margin-bottom: 8px;
		}
		
		.errors li {
			list-style: none;
		}

</style>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery-ui-1.10.3.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript" src="js/AddDeleteUser.js"></script>

<script>
	$(function() {
		$("#tabs").tabs();
	});

	$(document).ready(function(){
	 	 $.mobile.ajaxEnabled = false;
	  	 	$(".usernamesearchField").on("input", function(e) {
			var sugList=$('.avaialusers');
	    	var str="";
	        var text = $(this).val();
	        if(text.length < 1) {
	            sugList.html("");
	            sugList.listview("refresh");
	        } else {
	                $.get("http://server:8080/parvati/Getnameservlet",{methodetocall:'getusersname',name:text},function(res,code){
						for(var i = 0;i<res.split('#').length-1;i++)
							str += "<li><a href=javascript:addtosearchinputcname('"+res.split('#')[i]+"')>"+res.split('#')[i]+"</a></li>"; 
						 	
						 sugList.html(str);
			             sugList.listview("refresh");
		            });
	               
	        }
					
			});
	});

	function addtosearchinputcname(text){
		$('.usernamesearchField').val(text);
		$(".avaialusers").html("");
	}
	
</script>
</head>

<body>
	<div data-role="page">
		<div data-position="fixed" data-role="header" align="center"
			data-theme="b">
		<a href="menudisplay" data-role="buttun" data-icon="home">Menu</a>
			<div>&nbsp;</div>
			<div>
				<h1>PARVATI SOLVENTS EXTRACTION PVT LTD</h1>
			</div>
			<div>
				<h3>GUT NO.76, KHADGAON,TALUKA:
					BADNAPUR,DISTRICT:JALNA-431203,MAHARASHTRA,INDIA</h3>
			</div>
			
		</div>
		<br>
		<div data-role="content">
				
				<div id="tabs">
					<ul>
						<li><a href="#tabs-1">Add User</a></li>
						<li><a href="#tabs-2">Delete User</a></li>

					</ul>
					<div id="tabs-1">
						<form method="post" action="adduser">
						<s:if test="hasActionErrors()">
			   				<div class="errors">
			      				<s:actionerror/>
			   				</div>
						</s:if>
						<div data-role="controlgroup" data-type="horizontal"
							align="center">
							<label for="userid">User Id :</label> 
							<input type="text" id="userid" name="userid" required /><br>
						</div>
						<div data-role="controlgroup" data-type="horizontal"
							align="center">
							<label for="passwd">Password :</label> 
							<input type="text"	id="passwd" name="passwd" required />
						</div>
						<div data-role="controlgroup" data-type="horizontal"
							align="center">
							<label for="userid">Role :</label> 
							<select id="roleList" name="roles">
								<option value="admin">Admin</option>
								<option value="deo">DEO</option>
								<option value="labuser">LAB User</option>
								<option value="weightmachine">Weighing Machine Operator</option>
							</select>
						</div>
						<div data-role="controlgroup" data-type="horizontal"
							align="center">
							<button type="submit" data-role="button" id="btnadd" value="Add" data-theme="a"></button>

						</div>
						</form>
					</div>
					<div id="tabs-2">
					<form method="post" action="deleteuser">
						
						<s:if test="hasActionErrors()">
			   				<div class="errors">
			      				<s:actionerror/>
			   				</div>
						</s:if>
						
						<label for="userid">User Id :</label> 
						<input type="text" id="userid" class="usernamesearchField" name="userid" required /><br>
						<ul data-role="listview" class="avaialusers"></ul>
						<div data-role="controlgroup" data-type="horizontal"
							align="center">
							<button type="submit" data-role="button" id="btncan" value="Delete"
								data-theme="a"></button>
									
						</div>
					</form>
					</div>

				</div>
		</div>
	</div>
</body>